<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Contact;
use Faker\Generator as Faker;


$factory->define(Contact::class, function (Faker $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->email,
        'company_id' => function () {
            return factory(App\Company::class)->create()->id;
        },
        'company_size' => function ($contact) { // 公司规模 先查找公司 再获取 zize
            return App\Company::find($contact['company_id'])->size;
        },
        'vip_score' => 0
    ];
});

$factory->state(Contact::class, 'vip', function (Faker $faker) {
    return [
        'vip' => true,
        'vip_score' => mt_rand(1, 100),
    ];
});
$factory->state(Contact::class, 'normal', [
    'vip' => false,
]);
